package oc.tm.sg.core.monitor;

import java.io.Serializable;

/**
 * 统计数据
 * @author lry
 */
public class Statistics implements Serializable {
    
	private static final long serialVersionUID = 1L;
	
	private String id;

	//服务接口
    private String service;
    //服务分组
    private String group;
    //统计版本
    private String version;
    //被调度的方法
    private String method;
    
    //所属应用
    private String application;
    
    //调度日期:yyyy-MM-dd
    private String invoke_date;
    //调度开始时间戳
    private long invoke_time=0;
    
    //数据类型
    private String type;
    //供应者IP
    private String provider;
    //消费者的IP
    private String consumer;
    
    //数据字符串长度
    private long data_length=0;
    
    //调度成功次数
    private long success=0;
    //调度失败次数
    private long failure=0;
    
    //调度耗时(毫秒)
    private long elapsed=0;
    //调度并发个数
    private long concurrent=0;
    //最大调度耗时(毫秒)
    private long max_elapsed=0;
    //最大并发个数
    private long max_concurrent=0;
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getService() {
		return service;
	}
	public void setService(String service) {
		this.service = service;
	}
	public String getGroup() {
		return group;
	}
	public void setGroup(String group) {
		this.group = group;
	}
	public String getVersion() {
		return version;
	}
	public void setVersion(String version) {
		this.version = version;
	}
	public String getMethod() {
		return method;
	}
	public void setMethod(String method) {
		this.method = method;
	}
	public String getApplication() {
		return application;
	}
	public void setApplication(String application) {
		this.application = application;
	}
	public String getInvoke_date() {
		return invoke_date;
	}
	public void setInvoke_date(String invoke_date) {
		this.invoke_date = invoke_date;
	}
	public long getInvoke_time() {
		return invoke_time;
	}
	public void setInvoke_time(long invoke_time) {
		this.invoke_time = invoke_time;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getProvider() {
		return provider;
	}
	public void setProvider(String provider) {
		this.provider = provider;
	}
	public String getConsumer() {
		return consumer;
	}
	public void setConsumer(String consumer) {
		this.consumer = consumer;
	}
	public long getData_length() {
		return data_length;
	}
	public void setData_length(long data_length) {
		this.data_length = data_length;
	}
	public long getSuccess() {
		return success;
	}
	public void setSuccess(long success) {
		this.success = success;
	}
	public long getFailure() {
		return failure;
	}
	public void setFailure(long failure) {
		this.failure = failure;
	}
	public long getElapsed() {
		return elapsed;
	}
	public void setElapsed(long elapsed) {
		this.elapsed = elapsed;
	}
	public long getConcurrent() {
		return concurrent;
	}
	public void setConcurrent(long concurrent) {
		this.concurrent = concurrent;
	}
	public long getMax_elapsed() {
		return max_elapsed;
	}
	public void setMax_elapsed(long max_elapsed) {
		this.max_elapsed = max_elapsed;
	}
	public long getMax_concurrent() {
		return max_concurrent;
	}
	public void setMax_concurrent(long max_concurrent) {
		this.max_concurrent = max_concurrent;
	}

	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((application == null) ? 0 : application.hashCode());
		result = prime * result + (int) (concurrent ^ (concurrent >>> 32));
		result = prime * result + ((consumer == null) ? 0 : consumer.hashCode());
		result = prime * result + (int) (data_length ^ (data_length >>> 32));
		result = prime * result + (int) (elapsed ^ (elapsed >>> 32));
		result = prime * result + (int) (failure ^ (failure >>> 32));
		result = prime * result + ((group == null) ? 0 : group.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((invoke_date == null) ? 0 : invoke_date.hashCode());
		result = prime * result + (int) (invoke_time ^ (invoke_time >>> 32));
		result = prime * result + (int) (max_concurrent ^ (max_concurrent >>> 32));
		result = prime * result + (int) (max_elapsed ^ (max_elapsed >>> 32));
		result = prime * result + ((method == null) ? 0 : method.hashCode());
		result = prime * result + ((provider == null) ? 0 : provider.hashCode());
		result = prime * result + ((service == null) ? 0 : service.hashCode());
		result = prime * result + (int) (success ^ (success >>> 32));
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		result = prime * result + ((version == null) ? 0 : version.hashCode());
		return result;
	}

	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		
		Statistics other = (Statistics) obj;
		
		if (application == null) {
			if (other.application != null)
				return false;
		} else if (!application.equals(other.application))
			return false;
		
		if (consumer == null) {
			if (other.consumer != null)
				return false;
		} else if (!consumer.equals(other.consumer))
			return false;
		
		if (group == null) {
			if (other.group != null)
				return false;
		} else if (!group.equals(other.group))
			return false;
		
		if (method == null) {
			if (other.method != null)
				return false;
		} else if (!method.equals(other.method))
			return false;
		
		if (provider == null) {
			if (other.provider != null)
				return false;
		} else if (!provider.equals(other.provider))
			return false;
		
		if (service == null) {
			if (other.service != null)
				return false;
		} else if (!service.equals(other.service))
			return false;
		
		if (type == null) {
			if (other.type != null)
				return false;
		} else if (!type.equals(other.type))
			return false;
		
		if (version == null) {
			if (other.version != null)
				return false;
		} else if (!version.equals(other.version))
			return false;
		return true;
	}
	
	public String toString() {
		return "Statistics [id=" + id + ", service=" + service + ", group="
				+ group + ", version=" + version + ", method=" + method
				+ ", application=" + application + ", invoke_date="
				+ invoke_date + ", invoke_time=" + invoke_time + ", type="
				+ type + ", provider=" + provider + ", consumer=" + consumer
				+ ", data_length=" + data_length + ", success=" + success
				+ ", failure=" + failure + ", elapsed=" + elapsed
				+ ", concurrent=" + concurrent + ", max_elapsed=" + max_elapsed
				+ ", max_concurrent=" + max_concurrent + "]";
	}
    
}